import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/Home'
import Lunch from '@/pages/lunch/Lunch'
import Login from '@/pages/login/Login'
import Detail from '@/pages/detail/Detail'
import List from '@/pages/activitylist/List'
import Car from '@/pages/car/Car'
import User from '@/pages/user/User'
import Profiles from '@/pages/user/components/Profiles'
import LunchedList from '@/pages/user/components/LunchedList'
import JoinedList from '@/pages/user/components/JoinedList'
import Appraise from '@/pages/user/components/Appraise'
import Collect from '@/pages/user/components/Collect'
import ToAppraise from '@/pages/user/components/ToAppraise'
import Partner from '@/pages/user/components/Partner'
import UserDetail from '@/pages/detail/components/UserDetail'
import Admin from '@/pages/admin/Admin'
import Register from '@/pages/login/Register'
import forgetPasswrod from '@/pages/login/forgetPasswrod'
import forgetpsd_tele from '@/pages/login/forgetpsd_tele'
import AdminHome from '@/pages/admin/components/AdminHome'
import AdminCategory from '@/pages/admin/components/AdminCategory'
import AdminContent from '@/pages/admin/components/AdminContent'


Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      props: true
    },
    {
      path: '/lunch',
      name: 'Lunch',
      component: Lunch,
      props: true
    },
    {
      path: '/forgetPasswrod',
      name: 'forgetPasswrod',
      component: forgetPasswrod,
      props: true
    },
    {
      path: '/forgetpsd_tele',
      name: 'forgetpsd_tele',
      component: forgetpsd_tele,
      props: true
    },
    {
      path: '/login',
      name: 'Login',
      component: Login,
      props: true
    },{
      path: '/Register',
      name: 'Register',
      component: Register,
      props: true
    },
    {
      path: '/detail/:activityId',
      name: 'Detail',
      component: Detail,
      props: true,
      meta:{guard:true}
    },
    {
      path: '/list/:thirdId',
      name: 'List',
      component: List,
      props: true
    },
    {
      path: '/car',
      name: 'Car',
      component: Car,
      props: true,
      meta:{guard:true}
    },
    {
      path: '/user',
      name: 'User',
      component: User,
      props: true,
      meta:{guard:true}
    },
    {
      path: '/profiles/:userId',
      name: 'Profiles',
      component: Profiles,
      props: true
    },
    {
      path: '/lunchedlist/:userId',
      name: 'LunchedList',
      component: LunchedList,
      props: true
    },
    {
      path: '/joinedlist/:userId',
      name: 'JoinedList',
      component: JoinedList,
      props: true
    },
    {
      path: '/appraise/:userId',
      name: 'Appraise',
      component: Appraise,
      props: true
    },
    {
      path: '/collect/:userId',
      name: 'Collect',
      component: Collect,
      props: true
    },
    {
      path: '/toappraise',
      name: 'ToAppraise',
      component: ToAppraise,
      props: true
    },
    {
      path: '/userdetail/:userId',
      name: 'UserDetail',
      component: UserDetail,
      props: true,
      meta:{guard:true}
    },
    {
      path: '/partner/:userId',
      name: 'Partner',
      component: Partner,
      props: true
    },
    {
      path: '/admin',
      component: Admin,
      redirect: '/adminhome',
      children: [{
        path: '/adminhome',
        name:'AdminHome',
        component: AdminHome
      },{
        path: '/admincategory',
        name:'AdminCategory',
        component: AdminCategory
      },{
        path: '/admincontent',
        name:'AdminContent',
        component: AdminContent
      }],
      meta:{guard:true}
    }
  ]
});

// router.beforeEach((to,from,next)=> { 
//   let isLogin = localStorage.mine_dates
//   if(to.meta.guard){  //判断是否为true
//     if(isLogin){  判断是否为true
//       next()
//     }else{
//       next('/login')//不为true跳转到登录页面
//     }
//   }else{
//     next()//不为true往下执行
//   }
// })

export default router;
